package us.pigsoft.client;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Rectangle;

public class GuiButton extends GuiElement
{
	String text;
	Color font;
	Color unpressedColor;
	Color pressedColor;
	Color inColor;
	Color outColor;
	
	public GuiButton(int x, int y, Dimension size, Color outline, Color font, String text, String id)
	{
		super(x, y, size, outline, id);
		this.text = text;
		this.font = font;
		bounds = new Rectangle(x, y, size.width, size.height);
		unpressedColor = outline;
		pressedColor = outline.darker().darker();
		inColor = outline.darker();
		outColor = outline;
	}

	@Override
	public void click() {
		if(id.equals("playButton"))
		{
			// Starteth teh gamus
			MainInterface.me.game.running = false;
			MainInterface.me.fade(Game.State.Game);
			MainInterface.me.game.currentState = Game.State.Game;
			MainInterface.me.game.running = true;
		
			
		}
	}

	@Override
	public void draw(Graphics2D g) {
		// box outline
		g.setColor(outline);
		g.drawRect(x, y, size.width, size.height);
		
		// Draw text
		g.setColor(font);
		int len = g.getFontMetrics().stringWidth(text);
		int height = g.getFontMetrics().getHeight();
		g.drawString(text, x  + (((size.width) / 2) - len/2), y + ((size.height / 2) + height/3));
	}

	@Override
	public void entered(boolean in) {
		outline = (in) ? inColor : outColor;
		font = (in) ? inColor : outColor;
	}

	@Override
	public void release() {
		//outline = outline.brighter();
	}

	@Override
	public void pressed(boolean down) {
		outline = (down) ? pressedColor : inColor;
		font = (down) ? pressedColor : inColor;
	}

	@Override
	public void update() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyPressed(char key) {
		// TODO Auto-generated method stub
		
	}
}
